* Replication File for "Alliances and Civil War Intervention"
* Jesse C. Johnson, Brett Ashley Leeds, and Burcu Savun
* 9/5/24

set more off

* Open Data 
//use "JohnsonLeeds&SavunISQ.dta", clear

* Table 1

mlogit typeint consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id) 

* Table 2

mlogit typeint2 consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id) 

********************************************************************************

* Substantive Effects (Quantities Only - Code for Figures at End)

set seed 12345

* Figure 1

estsimp mlogit typeint consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id)

* Government Support

	setx median  
	setx rival 0 colony 0 premilint 1 rebelties 0 govties 0
		
	setx consul 0
	setx defense_pure 0
	setx neunon 0
	simqi, prval(1) genpr(pi1)
	sum pi1, d
		
	setx consul 0
	setx defense_pure 1
	setx neunon 0
	simqi, prval(1) genpr(pi2)
	sum pi2, d
	
	setx consul 1
	setx defense_pure 0
	setx neunon 0
	simqi, prval(1) genpr(pi3)
	sum pi3, d
	
* Rebel Support

	setx median  
	setx rival 0 colony 0 premilint 1 rebelties 0 govties 0
		
	setx consul 0
	setx defense_pure 0
	setx neunon 0
	simqi, prval(2) genpr(pi4)
	sum pi4, d
		
	setx consul 0
	setx defense_pure 0
	setx neunon 1
	simqi, prval(2) genpr(pi5)
	sum pi5, d
	
	drop pi1-pi5
	drop b1-b24
	
* Figure 2

estsimp mlogit typeint2 consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id)

* Government Troop Support

	setx median  
	setx rival 0 colony 0 premilint 1 rebelties 0 govties 0
		
	setx consul 0
	setx defense_pure 0
	setx neunon 0
	simqi, prval(1) genpr(pi1)
	sum pi1, d
	
	setx consul 0
	setx defense_pure 1
	setx neunon 0
	simqi, prval(1) genpr(pi2)
	sum pi2, d
	
	setx consul 1
	setx defense_pure 0
	setx neunon 0
	simqi, prval(1) genpr(pi3)
	sum pi3, d
	*drop b1-b48

* Government Non-Troop Support

*estsimp mlogit typeint2 consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id)
		
	setx median  
	setx rival 0 colony 0 premilint 1 rebelties 0 govties 0
		
	setx consul 0
	setx defense_pure 0
	setx neunon 0
	simqi, prval(2) genpr(pi4)
	sum pi4, d
	
	setx consul 0
	setx defense_pure 1
	setx neunon 0
	simqi, prval(2) genpr(pi5)
	sum pi5, d
	
	setx consul 1
	setx defense_pure 0
	setx neunon 0
	simqi, prval(2) genpr(pi6)
	sum pi6, d

	drop pi1-pi6
	drop b1-b48
	
* Figure 3

estsimp mlogit typeint2 consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id)

* Rebel Troop Support

	setx median  
	setx rival 0 colony 0 premilint 1 rebelties 0 govties 0
		
	setx consul 0
	setx defense_pure 0
	setx neunon 0
	simqi, prval(3) genpr(pi1)
	sum pi1, d
		
	setx consul 0
	setx defense_pure 0
	setx neunon 1
	simqi, prval(3) genpr(pi2)
	sum pi2, d
		
* Rebel Non-Troop Support

	setx median  
	setx rival 0 colony 0 premilint 1 rebelties 0 govties 0
		
	setx consul 0
	setx defense_pure 0
	setx neunon 0
	simqi, prval(4) genpr(pi3)
	sum pi3, d
		
	setx consul 0
	setx defense_pure 0
	setx neunon 1
	simqi, prval(4) genpr(pi4)
	sum pi4, d
	
	drop pi1-pi4
	drop b1-b48
		
* Examples

estsimp mlogit typeint2 consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id)

* Russia-Ukraine

	sort ccode1 ccode2 year

	setx [30381]		
	simqi, prval(3) genpr(u1)
	sum u1, d
	
	setx neunon 1 
	simqi, prval(3) genpr(u2)
	sum u2, d

* Russia-Syria

	sort ccode1 ccode2 year

	setx [127482]		
	simqi, prval(2) genpr(s1)
	sum s1, d
	
	setx consul 0 
	simqi, prval(2) genpr(s2)
	sum s2, d
	
	drop u1 u2 s1 s2
	drop b1-b48

********************************************************************************

* Appendix

* A1: Politically Relevant

mlogit typeint consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length if polrel==1, robust cluster(conflict_id) 

* A2: Politically Relevant

mlogit typeint2 consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length if polrel==1, robust cluster(conflict_id) 

* A3: Recode IGO Intervention

mlogit typeintX consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id) 

* A4: Recode IGO Intervention

mlogit typeintX2 consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id) 

* A5: Pure Consultation Pacts

mlogit typeint consul_pure defense neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id) 

* A6: Pure Consultation Pacts

mlogit typeint2 consul_pure defense neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id) 

* A7: Alliances Formed Before War

mlogit typeint consul_before consul_war defense_before defense_war neunon_before neunon_war rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id) 

* A8: Alliances Formed Before War

mlogit typeint2 consul_before consul_war defense_before defense_war neunon_before neunon_war rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id)

* A9: Additional Control Variables

mlogit typeint consul defense_pure neunon ln_bd reb_relstr reb_terr rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id) 

* A10: Additional Control Variables

mlogit typeint2 consul defense_pure neunon ln_bd reb_relstr reb_terr rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id) 

* A11: Aid Enemy

mlogit typeint consul defense_pure anyaidnon anynoaidnon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id) 

test [Rebel_Support]anyaidnon= [Rebel_Support]anynoaidnon

* A12: Consultation Matching Balance

cem defense_pure (#0) neunon (#0) rival (#0) rebelties (#0) govties (#0) capdist (0 5 25 50 100 200) colony (#0) caprat (0 .2 .4 .6 .8 1) premilint (#0) length (-1 10.5 20.5 30.5 50.5 72), treatment(consul)

* A13: Consultation Matching 

mlogit typeint consul rival rebelties govties capdist colony caprat premilint length [iweight=cem_weights], robust cluster(conflict_id) 

* A14: Consultation Matching

mlogit typeint2 consul rival rebelties govties capdist colony caprat premilint length [iweight=cem_weights], robust cluster(conflict_id) 

drop cem_strata cem_matched cem_weights

* A15: Defense Matching Balance

cem consul (#0) neunon (#0) rival (#0) rebelties (#0) govties (#0) capdist (0 5 25 50 100 200) colony (#0) caprat (0 .2 .4 .6 .8 1) premilint (#0) length (-1 10.5 20.5 30.5 50.5 72), treatment(defense_pure) 

* A16: Defense Matching 

mlogit typeint defense_pure rival rebelties govties capdist colony caprat premilint length [iweight=cem_weights], robust cluster(conflict_id)

* A17: Defense Matching

mlogit typeint2 defense_pure rival rebelties govties capdist colony caprat premilint length [iweight=cem_weights], robust cluster(conflict_id) 

drop cem_strata cem_matched cem_weights

* A18: Nonaggression Matching Balance

cem consul (#0) defense_pure (#0) rival (#0) rebelties (#0) govties (#0) capdist (0 5 25 50 100 200) colony (#0) caprat (0 .2 .4 .6 .8 1) premilint (#0) length (-1 10.5 20.5 30.5 50.5 72), treatment(neunon) 

* A19: Nonaggression Matching

mlogit typeint neunon rival rebelties govties capdist colony caprat premilint length [iweight=cem_weights], robust cluster(conflict_id)

* A20: Nonaggression Matching

mlogit typeint2 neunon rival rebelties govties capdist colony caprat premilint length [iweight=cem_weights], robust cluster(conflict_id)

drop cem_strata cem_matched cem_weights

* A21-A23: Sensitivity Analysis

reg intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id)

* Consultation

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(consul) benchmark(rival) clim(0 .3) kd(20) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(consul) benchmark(rebelties) clim(0 .3) kd(20) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(consul) benchmark(govties) clim(0 .3) kd(8) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(consul) benchmark(capdist) clim(0 .3) kd(3) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(consul) benchmark(colony) clim(0 .3) kd(20) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(consul) benchmark(caprat) clim(0 .3) kd(20) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(consul) benchmark(premilint) clim(0 .3) kd(20) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(consul) benchmark(length) clim(0 .3) kd(20) contourplot

* Defense

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(defense_pure) benchmark(rival) clim(0 .3) kd(20) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(defense_pure) benchmark(rebelties) clim(0 .3) kd(20) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(defense_pure) benchmark(govties) clim(0 .3) kd(20) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(defense_pure) benchmark(capdist) clim(0 .3) kd(5) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(defense_pure) benchmark(colony) clim(0 .3) kd(20) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(defense_pure) benchmark(caprat) clim(0 .3) kd(20) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(defense_pure) benchmark(premilint) clim(0 .3) kd(20) contourplot

sensemakr intgovt consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, suppress treat(defense_pure) benchmark(length) clim(0 .3) kd(20) contourplot

exit

********************************************************************************

* Code For Figures

set more off

* Open Data 
//use "JohnsonLeeds&SavunISQ.dta", clear

set seed 12345

*** Figure 1 ***

estsimp mlogit typeint consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id)

* Government Support

		generate xaxis=.
		gen simshigh=.
		gen simslow=.
		gen simspoint=.
		
		replace xaxis=1 in 1
		replace xaxis=3 in 2
		replace xaxis=5 in 3
	
		setx median  
		setx rival 0 colony 0 premilint 1 rebelties 0 govties 0
		
		setx consul 0
		setx defense_pure 0
		setx neunon 0
		simqi, prval(1) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 1
		replace simspoint=r(r2) in 1
		replace simshigh=r(r3) in 1
			drop pi1
		
		setx consul 0
		setx defense_pure 1
		setx neunon 0
		simqi, prval(1) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 2
		replace simspoint=r(r2) in 2
		replace simshigh=r(r3) in 2
			drop pi1

		setx consul 1
		setx defense_pure 0
		setx neunon 0
		simqi, prval(1) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 3
		replace simspoint=r(r2) in 3
		replace simshigh=r(r3) in 3
			drop pi1
			
# delimit ;

	sort xaxis;						

	twoway rbar simslow simshigh xaxis, barwidth(.05)
		||scatter simspoint xaxis, msymbol(circle) msize(huge) mcolor(black)
		xlabel(0 " " 1 "No Alliance" 2 " " 3 "Defense" 4 " " 5 "Consultation" 6 " ", labsize(large) notick)
		xtitle("")
		ytitle("Probability of Government Support")
		title("Government Support")
		legend(off)
		scheme(s1mono);

# delimit cr

drop xaxis simshigh simslow simspoint

* Rebel Support

		generate xaxis=.
		gen simshigh=.
		gen simslow=.
		gen simspoint=.
		
		replace xaxis=1 in 1
		replace xaxis=3 in 2
	
		setx median  
		setx rival 0 colony 0 premilint 1 rebelties 0 govties 0
		
		setx consul 0
		setx defense_pure 0
		setx neunon 0
		simqi, prval(2) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 1
		replace simspoint=r(r2) in 1
		replace simshigh=r(r3) in 1
		drop pi1
		
		setx consul 0
		setx defense_pure 0
		setx neunon 1
		simqi, prval(2) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 2
		replace simspoint=r(r2) in 2
		replace simshigh=r(r3) in 2
			drop pi1

# delimit ;

	sort xaxis;						

	twoway rbar simslow simshigh xaxis, barwidth(.05)
		||scatter simspoint xaxis, msymbol(circle) msize(huge) mcolor(black)
		xlabel(0 " " 1 "No Alliance" 2 " " 3 "Neutrality/Nonaggression" 4 " ",labsize(large) notick)
		ylabel(0 .001 .002 .003 .004)
		xtitle("")
		ytitle("Probability of Rebel Support")
		title("Rebel Support")
		legend(off)
		scheme(s1mono);

# delimit cr

	drop xaxis simshigh simslow simspoint
	drop b1-b24

*** Figure 2 ***
	
estsimp mlogit typeint2 consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id) nolog

* Government Troop Support

		generate xaxis=.
		gen simshigh=.
		gen simslow=.
		gen simspoint=.
		
		replace xaxis=1 in 1
		replace xaxis=3 in 2
		replace xaxis=5 in 3
	
		setx median  
		setx rival 0 colony 0 premilint 1 rebelties 0 govties 0
		
		setx consul 0
		setx defense_pure 0
		setx neunon 0
		simqi, prval(1) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 1
		replace simspoint=r(r2) in 1
		replace simshigh=r(r3) in 1
			drop pi1
		
		setx consul 0
		setx defense_pure 1
		setx neunon 0
		simqi, prval(1) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 2
		replace simspoint=r(r2) in 2
		replace simshigh=r(r3) in 2
			drop pi1

		setx consul 1
		setx defense_pure 0
		setx neunon 0
		simqi, prval(1) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 3
		replace simspoint=r(r2) in 3
		replace simshigh=r(r3) in 3
			drop pi1

# delimit ;

	sort xaxis;						

	twoway rbar simslow simshigh xaxis, barwidth(.05)
		||scatter simspoint xaxis, msymbol(circle) msize(huge) mcolor(black)
		xlabel(0 " " 1 "No Alliance" 2 " " 3 "Defense" 4 " " 5 "Consultation" 6 " ",labsize(large) notick)
		xtitle("")
		ytitle("Probability of Government Troop Support")
		title("Government Troop Support")
		legend(off)
		scheme(s1mono);

# delimit cr

	drop xaxis simshigh simslow simspoint

* Government Non-Troop Support

		generate xaxis=.
		gen simshigh=.
		gen simslow=.
		gen simspoint=.
		
		replace xaxis=1 in 1
		replace xaxis=3 in 2
		replace xaxis=5 in 3
	
		setx median  
		setx rival 0 colony 0 premilint 1 rebelties 0 govties 0
		
		setx consul 0
		setx defense_pure 0
		setx neunon 0
		simqi, prval(2) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 1
		replace simspoint=r(r2) in 1
		replace simshigh=r(r3) in 1
			drop pi1
	
		setx consul 0
		setx defense_pure 1
		setx neunon 0
		simqi, prval(2) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 2
		replace simspoint=r(r2) in 2
		replace simshigh=r(r3) in 2
			drop pi1

		setx consul 1
		setx defense_pure 0
		setx neunon 0
		simqi, prval(2) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 3
		replace simspoint=r(r2) in 3
		replace simshigh=r(r3) in 3
			drop pi1

# delimit ;

	sort xaxis;						

	twoway rbar simslow simshigh xaxis, barwidth(.05)
		||scatter simspoint xaxis, msymbol(circle) msize(huge) mcolor(black)
		xlabel(0 " " 1 "No Alliance" 2 " " 3 "Defense" 4 " " 5 "Consultation" 6 " ",labsize(large) notick)
		xtitle("")
		ytitle("Probability of Government Non-Troop Support")
		title("Government Non-Troop Support")
		legend(off)
		scheme(s1mono);
		
# delimit cr

	drop xaxis simshigh simslow simspoint
	drop b1-b48

*** Figure 3 ***

* Rebel Troop Support
	
estsimp mlogit typeint2 consul defense_pure neunon rival rebelties govties capdist colony caprat premilint length, robust cluster(conflict_id) nolog

		generate xaxis=.
		gen simshigh=.
		gen simslow=.
		gen simspoint=.
		
		replace xaxis=1 in 1
		replace xaxis=3 in 2
	
		setx median  
		setx rival 0 colony 0 premilint 1 rebelties 0 govties 0
		
		setx consul 0
		setx defense_pure 0
		setx neunon 0
		simqi, prval(3) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 1
		replace simspoint=r(r2) in 1
		replace simshigh=r(r3) in 1
			drop pi1
		
		setx consul 0
		setx defense_pure 0
		setx neunon 1
		simqi, prval(3) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 2
		replace simspoint=r(r2) in 2
		replace simshigh=r(r3) in 2
			drop pi1
		
# delimit ;

	sort xaxis;						

	twoway rbar simslow simshigh xaxis, barwidth(.05)
		||scatter simspoint xaxis, msymbol(circle) msize(huge) mcolor(black)
		xlabel(0 " " 1 "No Alliance" 2 " " 3 "Neutrality/Nonaggression" 4 " ",labsize(large) notick)
		xtitle("")
		ytitle("Probability of Rebel Troop Support")
		title("Rebel Troop Support")
		legend(off)
		scheme(s1mono);

# delimit cr

	drop xaxis simshigh simslow simspoint

* Other Rebel Support

		generate xaxis=.
		gen simshigh=.
		gen simslow=.
		gen simspoint=.
		
		replace xaxis=1 in 1
		replace xaxis=3 in 2
	
		setx median  
		setx rival 0 colony 0 premilint 1 rebelties 0 govties 0
		
		setx consul 0
		setx defense_pure 0
		setx neunon 0
		simqi, prval(4) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 1
		replace simspoint=r(r2) in 1
		replace simshigh=r(r3) in 1
			drop pi1
		
		setx consul 0
		setx defense_pure 0
		setx neunon 1
		simqi, prval(4) genpr(pi1)
		sum pi1, d
		_pctile pi1, p(2.5,50,97.5)
		replace simslow=r(r1) in 2
		replace simspoint=r(r2) in 2
		replace simshigh=r(r3) in 2
			drop pi1
		
# delimit ;

	sort xaxis;						

	twoway rbar simslow simshigh xaxis, barwidth(.05)
		||scatter simspoint xaxis, msymbol(circle) msize(huge) mcolor(black)
		xlabel(0 " " 1 "No Alliance" 2 " " 3 "Neutrality/Nonaggression" 4 " ",labsize(large) notick)
		xtitle("")
		ytitle("Probability of Rebel Non-Troop Support")
		title("Rebel Non-Troop Support")
		legend(off)
		scheme(s1mono);

	drop xaxis simshigh simslow simspoint
	drop b1-b48